{extend name='base' /}
{block name='content'}
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">后台管理</a>
        <a href="">文章管理</a>
        <a>
          <cite>回收站</cite></a>
      </span>
  <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
    <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
  <div class="layui-row">
    <form class="layui-form layui-col-md12 x-so" method="get">
      <input type="text" name="title" placeholder="请输入文章标题" autocomplete="off" class="layui-input" value="<?php echo $title = isset($_GET['title'])?$_GET['title']:'';?>">
      <?php  $cateid = isset($_GET['cateid'])?$_GET['cateid']:'';?>
      <div class="layui-input-inline " style="margin-top: -1px">
        <select name="cateid" >
          <option value="">请选择栏目</option>
          {volist name = 'CateData' id='vo'}
          <option value="{$vo.cate_id}" {if $cateid == $vo['cate_id']}selected{/if}>{$vo.cate_name}</option>
          {/volist}
        </select>
      </div>
      <button class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
    </form>

  </div>
  <xblock>
    <a href="javascript:allDel();" class="layui-btn layui-btn-danger"><i class="layui-icon layui-icon-delete"></i>清空回收站</a>
  </xblock>
  <table class="layui-table">
    <thead>
    <tr>

      <th>ID</th>
      <th>文章标题</th>
      <th>文章类别</th>
      <th>添加时间</th>
      <th>更改时间</th>
      <th>操作</th>
    </thead>
    <tbody>
{volist name='articleData' id='vo'}
    <tr>

      <td>{$vo.article_id}</td>
      <td>{$vo.title}</td>
      <td>
        {$vo.cate_name}
      </td>
      <td>{$vo.create_time}</td>
      <td>{$vo.update_time}</td>
      <td class="td-manage">
        <div class="layui-btn-group">
          <a class="layui-btn layui-btn-info layui-btn-xs" onclick="ups(this,{$vo.article_id})" href="javascript:;">还原</a>
          <a class="layui-btn layui-btn-danger layui-btn-xs" onclick="member_del(this,{$vo.article_id})" href="javascript:;">删除</a>
        </div>
      </td>
    </tr>
{/volist}
    </tbody>
  </table>
  <div class="page">
    <div>

    </div>
  </div>

</div>
<script>
    layui.use('laydate', function() {
        var laydate = layui.laydate;
        laydate.render({
            elem: '#test10'
            ,type: 'datetime'
            ,range: true
        });
    })


    /*用户-删除*/
    function member_del(obj,id){
        layer.confirm('确认要删除吗？', function (index) {
            // //发异步删除数据
            $.ajax({
                url: "{:url('article/del')}",
                data: {id: id},
                type: 'post',
                dataType: 'json',
                success: function (res) {
                    if (res.code) {
                        $(obj).parents("tr").remove();
                        layer.msg(res.message, {icon: 6, time: 1000});
                    } else {
                        layer.msg(res.message, {icon: 2, time: 1000})
                    }
                },
                error: function () {
                    layer.msg('出错了，请稍后再试！！', {icon: 5, time: 1000})
                }
            })

        });
    }

    function ups(obj,id) {
        layer.confirm('确认要还原吗？', function (index) {
            // //发异步删除数据
            $.ajax({
                url: "{:url('article/recovery')}",
                data: {id: id},
                type: 'post',
                dataType: 'json',
                success: function (res) {
                    if (res.code) {
                        $(obj).parents("tr").remove();
                        layer.msg(res.message, {icon: 6, time: 1000});
                    } else {
                        layer.msg(res.message, {icon: 2, time: 1000})
                    }
                },
                error: function () {
                    layer.msg('出错了，请稍后再试！！', {icon: 5, time: 1000})
                }
            })

        });
    }

    function allDel() {
        layer.confirm('确定清空？清空后不能恢复', function (index) {
            // //发异步删除数据
            $.ajax({
                url: "{:url('article/allDel')}",
                type: 'post',
                dataType: 'json',
                success: function (res) {
                    if (res.code) {
                        layer.msg(res.message, {icon: 6, time: 1000});
                        setTimeout(function () {
                            window.location.reload();
                        },1000)
                    } else {
                        layer.msg(res.message, {icon: 2, time: 1000})
                    }
                },
                error: function () {
                    layer.msg('出错了，请稍后再试！！', {icon: 5, time: 1000})
                }
            })

        });
    }

</script>

</body>
{/block}